package cl.blueprintsit.teaching.inheritance;

/**
 * This class is responsible for modeling a 2D point using a concrete
 * implementation based on polar coordinates.
 * 
 * @author andres
 *
 */
public class PointPolar implements IPoint {

	/** The angulus */
	private double theta;

	/** The radious */
	private double radious;

	/**
	 * This constructor is responsible for creating a Polar Point located at the
	 * origin.
	 */
	public PointPolar() {
		this.theta = 0;
		this.radious = 0;
	}

	/**
	 * This constructor is responsible for creating a full polar point using the
	 * angle and the radious.
	 * 
	 * @param theta The angle.
	 * @param radious The radious.
	 */
	public PointPolar(float theta, float radious) {
		this.theta = theta;
		this.radious = radious;
	}

	@Override
	public boolean isOrigin() {
		return this.radious == 0;
	}

	@Override
	public void move(IPoint point) {
		double x = point.getCartesianX();
		double y = point.getCartesianY();
		this.radious = (float) Math.sqrt(x*x + y*y);
		this.theta = (float) Math.atan2(x, y);
	}

	@Override
	public int getDistanceFromAnotherPoint(IPoint point) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public double getCartesianX() {
		double x = radious * Math.cos(theta);
		return x; 
	}

	@Override
	public double getCartesianY() {
		double y = radious * Math.sin(theta);
		return y;
	}

}
